package com.zb.file.controller;

import com.zb.annotation.SystemLog;
import com.zb.constant.OperationLogModuleType;
import com.zb.result.Result;
import com.zb.util.FileUploadUtil;
import com.zb.yaml.FilePath;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author WEN
 * @Date 2023/8/11 0011
 **/
@Api(tags = "文件删除接口")
@RestController
@RequestMapping("/file/delete")
public class DeleteFileController {

    @SystemLog(moduleType = OperationLogModuleType.FILE_MODULE_TYPE, remark = "文件附件 - 删除文件")
    @ApiOperation("删除文件")
    @DeleteMapping("/")
    public Result delete(@RequestBody @ApiParam(value = "删除的文件路径集合") List<String> paths) {
        FileUploadUtil.deleteFileBatchByPath(FilePath.domain(), FilePath.annexVisitPath(), FilePath.videoUploadPath(), paths);
        return Result.success("删除成功");
    }

    @SystemLog(moduleType = OperationLogModuleType.FILE_MODULE_TYPE, remark = "文件附件 - 删除文件")
    @ApiOperation("删除文件")
    @DeleteMapping("/mobile")
    public Result deleteMobile(@RequestBody @ApiParam(value = "删除的文件路径集合") List<String> paths) {
        FileUploadUtil.deleteFileBatchByPath(FilePath.domain(), FilePath.annexVisitPath(), FilePath.videoUploadPath(), paths);
        return Result.success("删除成功");
    }
}
